<?php error_reporting(0);
session_start(); 
if (isset($_SESSION['connect'])) {
?>
<?php
include 'config.php';
$tm=date("y.m.d G:i"); 
$ref=mysql_real_escape_string(htmlspecialchars($_POST["referer"]));
if(!($ref != NULL)){
$ref = "Unknown";
}
$agent=mysql_real_escape_string(htmlspecialchars($_POST["user_agent"]));
if(!($agent != NULL)){
$agent = "Unknown";
}
$ip=mysql_real_escape_string(htmlspecialchars($_POST["ip"]));
if(!($ip != NULL)){
die("You forgot to enter an ip <a href='admin.php'>Go back!</a>");
}
if(mysql_num_rows(mysql_query("SELECT ip FROM " . $tablename . " WHERE ip = '$ip'"))){
echo "already stored";
} else {
$strSQL = "INSERT INTO $tablename(tm, ref, agent, ip, tracking_page_name) VALUES ('$tm','$ref','$agent','$ip','$tracking_page_name')";
$test=mysql_query($strSQL);
}
header('Location: admin.php');
?>
<?php
}
else
{
header('Location: login.php');
}
?>

